package com.jingbian.cppccbackend.service.impl.admin;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.jingbian.cppccbackend.entity.ActivityOutcomes;
import com.jingbian.cppccbackend.mapper.admin.adminActivityOutcomesMapper;
import com.jingbian.cppccbackend.service.admin.ActivityOutcomesService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jingbian.cppccbackend.entity.vo.PageVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 活动成果表 服务实现类
 * </p>
 *
 * @author yezi
 * @since 2025-03-04
 */
@Service
public class adminActivityOutcomesServiceImpl extends ServiceImpl<adminActivityOutcomesMapper, ActivityOutcomes> implements ActivityOutcomesService {

    @Autowired
    adminActivityOutcomesMapper activitiesMapper;

    @Override
    public PageVO<ActivityOutcomes> getOutcomes(Integer pageNum, Integer pageSize, String sortType, String startDate, String endDate, String searchText) {
        PageVO<ActivityOutcomes> pb = new PageVO<>();
        PageHelper.startPage(pageNum, pageSize);
        List<ActivityOutcomes> outcomes = activitiesMapper.getOutcomes( sortType, startDate, endDate,searchText);
        Page<ActivityOutcomes> pag = (Page<ActivityOutcomes>) outcomes;
        pb.setTotal(pag.getTotal());
        pb.setItems(pag.getResult());
        return pb;
    }

    @Override
    public boolean deleteOutcome(Integer oid) {
        return activitiesMapper.deleteOutcome(oid);
    }

    @Override
    public ActivityOutcomes getOutcomeById(Integer oid) {
        return activitiesMapper.getOutcomeById(oid);
    }

    @Override
    public List<ActivityOutcomes> getOutcomesForExport(String sortType, String startDate, String endDate, String searchText) {
        return activitiesMapper.getOutcomes( sortType, startDate, endDate,searchText);
    }


}
